package com.alangyun.remind.initializer;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import com.alangyun.remind.RemindPreference;
import com.alangyun.remind.repository.StoreEngine;
import com.alangyun.remind.repository.cache.InstitutionCache;

@Component
@DependsOn("remind-pref")
public class SystemInitialization implements ApplicationRunner {
	private static boolean loaded = false;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		if(!loaded) {
			loaded = true;
			StoreEngine.init(RemindPreference.getDataPath());
			
			InstitutionCache.loadParams(RemindPreference.getDataPath());
		}
	}

}
